<template>
  <div>
  <h2 align="center">会员登录页面</h2>
  <table  border="1" align="center">
    <tr>
      <td>账号:</td>
      <td>
        <input type="text" v-model="state.zhang">
      </td>
    </tr>
    <tr>
      <td>密码:</td>
      <td>
        <input type="password" v-model="state.pwd"/>
      </td>
    </tr>
    <tr>
      <td></td>
      <td>
        <input type="button" value="登录" @click="login"/>
      </td>
    </tr>
  </table>
  </div>
</template>

<script setup lang="ts">
import { reactive,toRefs } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router = useRouter()

let data = reactive({
  state:{
    zhang:'',
    pwd:''
  }
})
let {state} = toRefs(data)

const login=()=>{
  if(state.value.zhang == ""){
    return alert("账号不能为空");
  }
  if(state.value.pwd == ""){
    return alert("密码不能为空");
  }
  axios({
    url:'/api/Member/GetAdmin',
    method:'get',
    params:state.value
  })
  .then(res=>{
    console.log(res)
    if(res.data.data == null){
      return alert("手机号或密码错误")
    }
    else{
      alert("登录成功");
      router.push('/adminList')
    }
  }).catch(err=>{
    console.log(err)
  })
}
</script>

<style scoped>

</style>